<template>
  <el-dialog :model-value="visible" :top="marginTop" class="marginBottom" :close-on-click-modal="false" :title="title" :width="width + 'px'"
    :height="height + 'px'" destroy-on-close :before-close="onClose" :draggable="false" append-to-body>
    <div class="container" :style="{ height: height + 'px' }">
      <slot name="content" />
    </div>
    <template #footer v-if="showFooter">
      <span class="dialog-footer">
        <el-button @click="onClose">取消</el-button>
        <el-button type="primary" @click="onConfirm">确定</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script setup lang='ts'>
import { reactive, ref } from 'vue'
const props = defineProps({
  title: {//弹框标题
    type: String,
    default: '标题'
  },
  visible: { //控制弹框的展示和影藏
    type: Boolean,
    default: true
  },
  width: {
    type: Number,
    default: 600
  },
  height: {
    type: Number,
    default: 250
  },
  showFooter: {
    type: Boolean,
    default: true
  },
  marginTop:{
    type:String,
    default:'15vh'
  }
})
const emit = defineEmits(['onClose', 'onConfirm'])
const onClose = () => {
  emit('onClose')
}
const onConfirm = () => {
  emit('onConfirm')
}
</script>
<style lang="scss" scoped>
.container {
  overflow-x: initial;
  overflow-y: auto;
}
.el-dialog{
  border-top-left-radius: 7px !important;
  border-top-right-radius: 7px !important;
  // margin-top: 15vh !important;
  margin-bottom: 0 !important;
  .el-dialog__header {
    .el-dialog__headerbtn {
      top: 0px;
    }

    border-top-left-radius: 7px !important;
    border-top-right-radius: 7px !important;
    background-color: #1890ff !important;
    margin-right: 0;

    .el-dialog__title {
      color: #fff;
      font-size: 16px;
      font-weight: 600;
    }

    .el-dialog__close {
      color: #fff;
    }
  }

  .el-dialog__body {
    padding: 10px;
  }

  .el-dialog__footer {
    border-top: 1px solid #e8eaec !important;
    padding: 10px;
    display: flex;
    justify-content: center;
  }
}
</style>
<style lang="scss">
.marginBottom{
  margin-bottom: 0 !important;
}
</style>